<!DOCTYPE html>
<html>
<body>
<h2>💬 与 Qwen 模型聊天</h2>
<input id="msg" placeholder="说点什么..." />
<button onclick="send()">发送</button>
<pre id="log"></pre>

<script>
  const ws = new WebSocket("ws://localhost:8080/ws")

  ws.onmessage = e => {
    // 每次只显示当前回答（不追加）
    document.getElementById("log").textContent += e.data
  }

  function send() {
    const msg = document.getElementById("msg").value
    document.getElementById("log").textContent = "" // 清空旧内容
    ws.send(msg)
  }
</script>
</body>
</html>
